/*
 * @Date: 2023-03-23 15:11:16
 * @LastEditTime: 2023-05-17 18:01:50

 * 介绍:
 */
import { multiply } from "mathjs";
export function unitPx(pixel: string | undefined | number): string {
  return (pixel || 0) + "px";
}
export function unitRem(pixel: string | undefined | number): string {
  return (pixel || 0) + "rem";
}
export function unitVmax(pixel: string | undefined | number): string {
  return (pixel || 0) + "vmax";
}
export function unitVmin(pixel: string | undefined | number): string {
  return (pixel || 0) + "Vmin";
}

export function remToPx(rem: number) {
  const fontSize = document.documentElement.style.fontSize.replace(/px$/, "");
  return multiply(rem, Number(fontSize));
}
